All Questions
18 questions
0votes
2answers
685views
How to create an interface in C that can work on two identical structs with differently named fields
Question Background Consider a scenario in which I have two structs. Both consist of three fields for doubles. The only difference is the names used to refer to these fields. The first struct is for ...
1vote
2answers
217views
physical simulation: design thoughts
I'm an applied physics student and currently working on a simulation of the magnetic interactions of multiple protons within a protein. Me having only little experience with programming and almost ...
2votes
3answers
553views
What is the name of this pattern (if any)?
There's a sort of pattern that I've sort of stumbled myself into "discovering" that seems extremely useful, but I've never seen it described before. It's sort of a way of achieving inheritance through ...
0votes
3answers
402views
Documenting my code using generic Design Patterns interfaces
Background I've been thinking about documenting design patterns in our code by setting up interfaces for the common design patterns so that when people read my code it would be clear that I am using ...
0votes
3answers
368views
Send records using async or sync way
I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K ...
2votes
1answer
583views
Is this a good way to keep track of subscription cycles and figure out if we need to charge the subscriber?
I'm working in PHP and building a subscription management system from scratch. I'm trying to figure out the required functions for the Subscription interface (OOP) that need to be implemented by ...
1vote
1answer
1kviews
Inheritance is better or composition design pattern in this scenario?
Design and implement Cash Register: Given a number of items you will be required to calculate the total bill. Items are charged for in a couple of different ways: A given price for each item, e.g. ...
10votes
3answers
7kviews
Using Interfaces for Loosely Coupled Code
Background I have a project that depends on the usage of a certain type of hardware device, while it doesn't really matter who makes that hardware device as long as it does what I need it to do. With ...
2votes
1answer
617views
Define an object with the interface as a type instead of class name [duplicate]
I try to practice with the design patterns and explore one of the possible implementations of the Observer Design Pattern in Java. I paid attention, that in this example the object is defined with the ...
-4votes
2answers
192views
Advantages of these recommendations in ooprogramming using Java
Below are the recommendation from section 5.1 of this essay. While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following ...
9votes
4answers
5kviews
How to force "program to an interface" without using a java Interface in java 1.6
In java 1.8 they have wonderful new "default interface methods". In 1.6 how close can we come? The goal: use code to keep clients from being able to tell that a class is not a java interface. If we ...
2votes
2answers
868views
Should an abstract class always abstract its methods to an interface?
I had learned sometime ago that abstract classes should always abstract their functions to an interface. So instead of having something like this - abstract class a{ public int i; public int ...
3votes
5answers
2kviews
Explanation of the definition of interface inheritance as described in GoF book
I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: Class versus Interface Inheritance It's important to understand the difference between an ...
6votes
1answer
1kviews
How does dependency inversion principle work in languages without interfaces?
In C#/Java, the dependency inversion principle is often demonstrated by high-level classes that depends on an interface/abstraction (that it owns). Low-level classes will implement the interface, thus ...
36votes
10answers
26kviews
Interfaces on an abstract class
My coworker and I have different opinions on the relationship between base classes and interfaces. I'm of the belief that a class should not implement an interface unless that class can be used when ...